Skip to content

Claude: separate model discovery proxy - #395

Open
andy-xu-db wants to merge 9 commits into
mainfrom
andy.xu/claude-model-discovery-proxy
Open

Claude: separate model discovery proxy#395
andy-xu-db wants to merge 9 commits into
mainfrom
andy.xu/claude-model-discovery-proxy

Conversation

@andy-xu-db

Copy link
Copy Markdown
Collaborator

Summary

  • keep token refresh, retry, forwarding, and streaming in the shared gateway proxy
  • move Anthropic model prefixing and stripping into a discovery handler subclass
  • use the discovery subclass for both standard and relayed Claude launches

Testing

  • uv run --frozen ruff check src/ tests/
  • uv run --frozen ty check src/
  • uv run --frozen pytest tests/test_gateway_proxy.py tests/test_anthropic_model_discovery_proxy.py tests/test_agent_claude.py tests/test_lint.py -q
  • uv run --frozen pytest -q --ignore=tests/test_e2e_user_agent.py (1951 passed, 37 skipped)

Stacked on #375.

@andy-xu-db
andy-xu-db force-pushed the andy.xu/claude-model-discovery-proxy branch from 0bb4d25 to 2ad807d Compare August 26, 2026 02:04
@andy-xu-db
andy-xu-db changed the base branch from andy.xu/claude-gateway-model-aliases to main August 26, 2026 02:04
@andy-xu-db
andy-xu-db requested a review from lilly-luo August 26, 2026 16:42
token_header: str,
force_refresh_near_expiry: bool,
):
return gateway_proxy._start_proxy(

@lilly-luo lilly-luo Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally _ prefix is saved for private methods that aren't called outside of the file. can you use the public start_proxy instead? then you can override _start_proxy in the original gateway_proxy one and invoke it in the public start_proxy

Comment thread src/ucode/gateway_proxy.py Outdated
bytes_relayed = 0
first_byte_ms: int | None = None
try:
transformed_body = self._transform_response(resp)

@lilly-luo lilly-luo Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can you transform the response if the req hasn't been sent yet?

Comment thread src/ucode/gateway_proxy.py Outdated
Comment on lines +332 to +335
response_chunks = (
[transformed_body] if transformed_body is not None else resp.iter_raw()
)
for chunk in response_chunks:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was the cause of issues for relayed auth that customer reported, we should be careful changing this. also does this mean that if a relayed auth request is sent for inference on a session that has model discovery enabled, we wouldn't be doing resp.iter_raw?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants